$(document).ready(function() {
    // Submit Confirm Dialog
	
	$('#topComment').dialog({
        autoOpen: false,
        modal: true,                  // 是否使用模式窗口，模式窗口打开后，页面其他元素将不能点击，直到关闭模式窗口。
        closeOnEscape: true,           // true: 点击键盘ESC键关闭dialog
        width: 300, minWidth: 300, maxHeight: 600,
       // minHeight: 120, maxHeight: 120,
        resizable: false,
        draggable: false
    });
	
	
	
	 $('#Print').dialog({
        autoOpen: false,
        modal: true,                  // 是否使用模式窗口，模式窗口打开后，页面其他元素将不能点击，直到关闭模式窗口。
        closeOnEscape: true,           // true: 点击键盘ESC键关闭dialog
        width: 300, minWidth: 300, 
       
        resizable: true,
        draggable: false
    });
	 $('#export').dialog({
        autoOpen: false,
        modal: true,                  // 是否使用模式窗口，模式窗口打开后，页面其他元素将不能点击，直到关闭模式窗口。
        closeOnEscape: true,           // true: 点击键盘ESC键关闭dialog
        width: 300, minWidth: 300, 
       
        resizable: true,
        draggable: false
    });
	 $('#Password').dialog({
        autoOpen: false,
        modal: true,                  // 是否使用模式窗口，模式窗口打开后，页面其他元素将不能点击，直到关闭模式窗口。
        closeOnEscape: true,           // true: 点击键盘ESC键关闭dialog
        width: 300, minWidth: 300, 
       
        resizable: true,
        draggable: false
    });
});



function showComment(){
	if($('#Comment').dialog( 'isOpen' )){	
		$('#Comment').dialog( 'close' );
	}else{
		$('#Comment').dialog( 'open' );
	}	
}

function showPrint(){
	if($('#Print').dialog( 'isOpen' )){	
		$('#Print').dialog( 'close' );
	}else{
		$('#Print').dialog( 'open' );
	}	
}

function showexport(){
	if($('#export').dialog( 'isOpen' )){	
		$('#export').dialog( 'close' );
	}else{
		$('#export').dialog( 'open' );
	}	
}
function showpsd(){
	if($('#Password').dialog( 'isOpen' )){	
		$('#Password').dialog( 'close' );
	}else{
		$('#Password').dialog( 'open' );
	}	
}



/*
 * Url preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.screenshotPreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='screenshot'>"+ this.t +"</p>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	screenshotPreview();
});



$(function(){

$("#Documentsradio").click(function(){
    if($("#Documentsradio").is(":checked"))
             {$("#Documentstr").css("display","");}
			 else{$("#Documentstr").css("display","none");}	
})




})

function printReinspectionActionSubmit(){		
	var radio=getCbxByName("radio");
	var version=getCbxByName("version");
	if(radio==""&&version==""){
		alert("必须选择一项，请重新操作。");
		
		return false;
	}else{
		showPrint();
		document.printForm.submit();
	}

}

function printActionSubmit(){
	var radio=getCbxByName("radio");
	var doc=getCbxByName("documents");
	var version=getCbxByName("version");
	if(radio==""&&doc==""){
		alert("必须选择一项，请重新操作。");	
		return false;
	}else{
		if(version==""&&radio==""){
			alert("必须选择一项，请重新操作。");			
			return false;
		}
		showPrint();
		document.printForm.submit();
	}

}

function getCbxByName(s){   
	var cbx = document.getElementsByName(s);   
	var value="";
	for(var i=0;i<cbx.length;i++){   
		if (cbx[i].checked){   
				value += cbx[i].value+",";
		}   
	}   
	return value;   
}

function tableShowOrHide(obj,needHideId)
{
	
	var hideObject=$("#"+needHideId);
	if(hideObject.css("display") =='none'){
		hideObject.css("display","");
		obj.src="../images/common/down.gif";
	}else{
		hideObject.css("display","none");
		obj.src="../images/common/up.gif";
	}
}

function unselectall(){
if(document.myform.chkAll.checked){
document.myform.chkAll.checked = document.myform.chkAll.checked&0;
}
}
function CheckAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.Name != 'chkAll'&&e.disabled==false)
e.checked = form.chkAll.checked;
}
}

function tableShowOrHide2(obj,selTable)
{
	selTable.style.display=(selTable.style.display =='none')?'':'none';
	if(selTable.style.display =='none'){
		if(typeof $contextPath != 'undefined'){
			obj.src=$contextPath + "../images/common/down.gif";
		}else{
			obj.src="../images/table_btn.gif";
		}
	}else{
		if(typeof $contextPath != 'undefined'){
			obj.src=$contextPath + "../images/common/up.gif";
		}else{
			obj.src="../images/img_btn.gif";
		}
	}
}

function showorhidetable(){
 if($('#reporttable').css("display")=="none"){
    $('#imgreport').css("display","none");
    $('#reporttable').css("display","");
    $('#advancedSearch2').css("display","none");           
   } else{
	  if($("input[name='radio']:checked").val()=="show"){
		  	$('#imgreport').css("display","none");
	      $('#reporttable').css("display","none");
	      $('#advancedSearch2').css("display","");
	  }else{
	      $('#imgreport').css("display","");
	      $('#reporttable').css("display","none");
	      $('#advancedSearch2').css("display","none");
	  }
   }
}

function shownumber(){
 $('#imgreport').css("display","none");
 $('#reporttable').css("display","none");
$('#advancedSearch2').css("display","");
                
}
function hidenumber(){
$('#imgreport').css("display","");

$('#advancedSearch2').css("display","none");
$('#reporttable').css("display","none");
                
}